package com.study.concurrentprogramming.threadLocal;

import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;

public class ThreadLocalTest {

    private static final ThreadLocal<String> threadLocal = new ThreadLocal<String>();

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            threadLocal.set("hello");
            System.out.println(threadLocal.get());
            Thread thread1 = Thread.currentThread();
            System.gc();
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Thread thread = Thread.currentThread();
            System.out.println(threadLocal.get());
        }).start();

    }

}
